﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YTCMS.Core;
using YTCMS.Services.Services;

namespace App.Areas.Wap.Controllers
{
    public class HomeController : Controller
    {
        private readonly IproductsService _product;
        private readonly IcmscolumnService _cmscolumn;
        private readonly IcolumnproductService _columnproduct;
        public HomeController(IproductsService product, IcmscolumnService cmscolumn, IcolumnproductService columnproduct)
        {
            this._product = product;
            this._cmscolumn = cmscolumn;
            this._columnproduct = columnproduct;
        }
        //
        // GET: /Wap/Home/
        public ActionResult Index()
        {
            var push = _product.Get(s => s.IsPush == 1);
            ViewData["push"] = push;

            var columns = _cmscolumn.GetMany(s => s.State == (int)CommonState.正常 && s.module.Code.Equals("WAPHome") && s.module.Type.Equals("WAP"), Order.desc, "Sort");
            return View(columns);

        }

        public ActionResult Add(int cid ,int top)
        {
            var model = _columnproduct.GetMany(s => s.Cid == cid,Order.desc,"Sort");
            model = model.Skip(top).Take(6) ;
            return PartialView("List", model);
        }
	}
}